#include "stdafx.h"
#include "Rasterizer.h"
#include "RTXCode/vec3.h"

Rasterizer::Rasterizer(RenderContext* pcontext)
{
	context = pcontext;
}

Rasterizer::~Rasterizer()
{

}

void Rasterizer::DrawPixel(int x, int y, Color& c)
{
	context->backBuffer[x + y* context->width] = (c.GetUintA() << 24) | (c.GetUintR() << 16) | (c.GetUintG() << 8) | (c.GetUintB() << 0);
}

void Rasterizer::DrawPixel(int x, int y, vec3& v)
{
	int r = int(v[0] * 255);
	int g = int(v[1] * 255);
	int b = int(v[2] * 255);
	context->backBuffer[x + y * context->width] = 16777216 | (r << 16) | (g << 8) | b;
}